package com.wsx.first.c;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @author: wangshunxi
 * @date: 2022/5/10 16:22
 * @Description:
 */
public class Main0005 {
    public static final List<Character> x = Arrays.asList('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String content = scanner.nextLine();

            solution(content);
        }
    }

    private static void solution(String content) {
        if (content == null) {
            System.err.println(-1);
        } else if (content.length() <= 2) {
            System.err.println(-2);
        } else {
            String substring = content.substring(2, content.length());
            char[] chars = substring.toCharArray();
            int val = 0;
            int ba = 1;
            for (int i = chars.length - 1; i >= 0; i--) {
                char aChar = chars[i];
                int i1 = x.indexOf(aChar);
                val = val+i1 *ba;
                ba = ba * 16;
            }
            System.out.println(val);
        }


    }
}
